package example.java.lang.reflect.InvocationHandler;

import java.lang.reflect.Proxy;

public class Main {
	public static void main(String[] args) {
		ArithmeticCalculator arithmeticCalculatorImpl = new ArithmeticCalculatorImpl();
		
//		ArithmeticCalculator arithmeticCalculator = (ArithmeticCalculator) Proxy.newProxyInstance(arithmeticCalculatorImpl.getClass().getClassLoader(), arithmeticCalculatorImpl.getClass().getInterfaces(), new CalculatorLoggingHandler(arithmeticCalculatorImpl));
		
//		ArithmeticCalculator arithmeticCalculator = (ArithmeticCalculator) CalculatorLoggingHandler.createProxy(arithmeticCalculatorImpl);
		
		ArithmeticCalculator arithmeticCalculator = (ArithmeticCalculator) CalculatorValidationHandler.createProxy(CalculatorLoggingHandler.createProxy(arithmeticCalculatorImpl));
		
		arithmeticCalculator.add(3, 4);
		
//		arithmeticCalculator.add(-3, 4);
		
		UnitCalculator unitCalculatorImpl = new UnitCalculatorImpl();
		UnitCalculator unitCalculator = (UnitCalculator) CalculatorLoggingHandler.createProxy(CalculatorValidationHandler.createProxy(unitCalculatorImpl));
		
		unitCalculator.kilogramToPound(10);
		
		unitCalculator.kilogramToPound(-10);
	}
}
